//
//  XDExchangeCell.m
//  XDEducation
//
//  Created by 星道 on 17/5/12.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDExchangeCell.h"

#define QuantityH 12

@implementation XDExchangeCell
{
    IBOutlet UIImageView *_img;
    IBOutlet UILabel     *_title;
    IBOutlet UIButton    *_change;
    IBOutlet UILabel     *_quantity;
    
    IBOutlet NSLayoutConstraint *_quantityLayout;
}


- (void)setModel:(XDExchangeModel *)Model
{
    _Model = Model;
    
    //图片
    _img.image = [UIImage imageNamed:Model.ImgName];
    //名称
    _title.text = Model.Title;
    //数量
    _quantity.text = [NSString stringWithFormat:@"%ld",Model.Quantity];
    
    
    /** 样式变化 */
    //button与label位置
    if (Model.IsChange == NO) return;
    
    if (self.Model.IsShow == NO)
    {
        _change.hidden = YES;
        _quantityLayout.constant -= QuantityH;
        Model.IsChange = NO;
    }

}


#pragma mark - Action
//兑换
- (IBAction)ExchangeAction:(UIButton *)sender
{
    self.ExChangeAction (self.Model);
}

@end
